package cn.com.chec.en.controller.front;

import java.util.List;
import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.log4j.Logger;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import cn.com.chec.en.dao.ChannelInfoDao;
import cn.com.chec.en.dao.PageLinkDao;
import cn.com.chec.en.model.domain.ChannelInfo;
import cn.com.chec.en.util.ContactUtils;

@Controller
public class WebsiteMapFrontController {
	protected static final Logger logger = Logger
			.getLogger(WebsiteMapFrontController.class);

	@Resource
	private PageLinkDao pageLinkDao;

	@Resource
	private Map<String, Object> environment;

	@Resource
	private ChannelInfoDao channelInfoDao;

	@RequestMapping(value = { "/map" }, method = { org.springframework.web.bind.annotation.RequestMethod.GET })
	public ModelAndView websiteMap(HttpServletRequest request,
			HttpServletResponse response, ModelMap map) {
		ModelAndView mav = new ModelAndView("websiteMap");

		Map<String, String> pageLinkMap = this.pageLinkDao.getAllAsMap();
		logger.info("[NewsFrontController] pageLinkMap=" + pageLinkMap);
		map.put("pageLinkMap", pageLinkMap);

		map.putAll(ContactUtils.getContactMap());
		map.putAll(this.environment);

		List<ChannelInfo> channelInfoList_business = this.channelInfoDao
				.getSubListByParentIdLanguageId(1, 2, 0, 2147483647);
		map.put("channelInfoList_business", channelInfoList_business);

		List<ChannelInfo> channelInfoList_dev = this.channelInfoDao
				.getSubListByParentIdLanguageId(1, 3, 0, 2147483647);
		map.put("channelInfoList_dev", channelInfoList_dev);

		List<ChannelInfo> channelInfoList_joinUs = this.channelInfoDao
				.getSubListByParentIdLanguageId(1, 5, 0, 2147483647);
		map.put("channelInfoList_joinUs", channelInfoList_joinUs);

		List<ChannelInfo> channelInfoList_aboutUs = this.channelInfoDao
				.getSubListByParentIdLanguageId(1, 6, 0, 10000);
		map.put("channelInfoList_aboutUs", channelInfoList_aboutUs);

		mav.addAllObjects(map);
		return mav;
	}
}